//
//  Macro.h
//  OC_Poj_demo
//
//  Created by weixin on 2018/6/24.
//  Copyright © 2018年 weixn. All rights reserved.
//

#ifndef Macro_h
#define Macro_h



//屏幕尺寸
#define kScreenW [UIScreen mainScreen].bounds.size.width
#define kScreenH [UIScreen mainScreen].bounds.size.height
#define kScreenSCALE  ([UIScreen mainScreen].scale)
#define kScreenBOUNDS [UIScreen mainScreen].bounds



//iphone
#define Is_Iphone        (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define Is_Iphone_XS_MAX (Is_Iphone && kScreenH == 896.0)
#define Is_Iphone_XS     (Is_Iphone && kScreenH == 812.0)
#define Is_Iphone_XR     (Is_Iphone && kScreenH == 896.0)
#define Is_Iphone_X      (Is_Iphone && kScreenH == 812.0)
#define Is_Iphone_6p     (Is_Iphone && kScreenH == 736.0)
#define Is_Iphone_6      (Is_Iphone && kScreenH == 667.0)
#define Is_Iphone_5      (Is_Iphone && kScreenH == 568.0)
#define Is_Iphone_4      (Is_Iphone && kScreenH == 480.0)

#define Is_Iphone_X_Series ( Is_Iphone_X || Is_Iphone_XR || Is_Iphone_XS_MAX || Is_Iphone_XS)

#define NaviHeight          (Is_Iphone_X_Series ? 88 : 64)
#define TabbarHeight        (Is_Iphone_X_Series ? 83 : 49)
// 底部安全区域远离高度
#define kBottomSafeHeight   (Is_Iphone_X_Series ? 34 : 0)
// 顶部安全区域远离高度
#define kTopBarSafeHeight   (CGFloat)(Is_Iphone_X_Series?(44):(0))
//状态栏高度
#define kStatusBarHeight    (CGFloat)(Is_Iphone_X_Series?(44):(20))
//刘海高度
#define kStatusBarHeight2    (CGFloat)(Is_Iphone_X_Series?(30):(20))


// 苹果6的高度
#define kIphone6Height 667.0
// 苹果6的宽度
#define kIphone6Width 375.0
// 苹果5的搞度
#define kIphone5Height 568.0
// 苹果5的宽度
#define kIphone5Width 320.0
//APP
#define APP_VERSION ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"])
//APP BUILD
#define APP_BUILD ([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"])

/**
 用户信息
 */
#define kUUID @"kUUID" //设备UUID
#define kUUID_USER_ID @"kUUID_USER_ID" //用户ID - 根据UUID请求获得
#define kUSER_DEFAULTS [NSUserDefaults standardUserDefaults]
#define kUSER_DEFAULTS_USER_ID @"kUSER_DEFAULTS_USER_ID"//UserDefault保存用户ID
#define kUSER_TOKEN @"kUSER_TOKEN" //UserDefault保存用户Token
#define kUSER_INFO @"kUSER_INFO" //UserDefault保存用户信息Key
#define kIDFA [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]

/**
 颜色参数可能在 同一整理到 UIColor+Extension
 */

//颜色设置
#define RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

#define RGB(r,g,b) RGBA(r,g,b,1.0f)

#define HexColor(HexValue) [UIColor colorWithRed:((float)((HexValue & 0xFF0000) >> 16))/255.0 green:((float)((HexValue & 0xFF00) >> 8))/255.0 blue:((float)(HexValue & 0xFF))/255.0 alpha:1.0]

// 随机色
#define RandomColor RGB(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

#pragma mark - --- 常用颜色
//导航栏颜色
#define NaviColor               RGB(242,242,242)
//控制器 控件等 默认背景色
#define kBackColorDefault       RGB(255,255,255)
//默认字体颜色
#define kColorTextDefault       RGB(255,255,255)
//标题颜色
#define kColorTextTit           RGB(255,255,255)

//标题颜色
#define kMainColor           RGB(0,120,190)
#define kMainColorGray       RGB(89,89,89)


#pragma mark - --- Images
#define kIMAGE_URL_PREFIX @"http://mtime-1252014125.file.myqcloud.com"
#define kIMAGE_URL(url) kSTRING_FORMAT(@"%@%@",kIMAGE_URL_PREFIX, url)
#define kIMAGE_NAME(name) [UIImage imageNamed:(name)]
#define kUSER_ICON_IMAGE kIMAGE_NAME(@"Me_User_Icon")
#define kSQUARE_PLACEHOLDER_IMAGE kIMAGE_NAME(@"Base_SquarePlaceholderImage")


#pragma mark - --- 基于5的适配
//控件尺寸适配
#define kFit(x)                 (kScreenW*((x)/kIphone5Width))

// 适配
#define kFLOAT(x)  ((x)/375.0f) * kScreenW
#define kFONT(x)   [UIFont systemFontOfSize:kFLOAT(x)]

#define kIPHONE_40_INCH ((kSCREEN_WIDTH == 320.f && kSCREEN_HEIGHT == 568.f) ?YES :NO)
#define kIPHONE_47_INCH ((kSCREEN_WIDTH == 375.f && kSCREEN_HEIGHT == 667.f) ?YES :NO)
#define kIPHONE_55_INCH ((kSCREEN_WIDTH == 414.f && kSCREEN_HEIGHT == 736.f) ?YES :NO)
#define kIPHONE_X       ((kSCREEN_WIDTH == 375.f && kSCREEN_HEIGHT == 812.f) ?YES :NO)


#pragma mark - --- 字体
//定义字体函数
#define FONT(x)                 [UIFont systemFontOfSize:x]
#define BFONT(x)                [UIFont boldSystemFontOfSize:x]
//字体适配手机
#define kFontFit(x)             FONT(kFit(x))
#define kBFont(x)               BFONT(kFit(x))

//常用字体大小
//默认字体 14号字体
#define kFontTextDeafult        kFontFit(14)
//标题 15号
#define kFontTitDefault         kFontFit(15)

#ifdef DEBUG

#define DLog(s, ...) printf("< 文件名:%s  行号::(%d) > \n[方法名:%s] \n%s\n", [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(s), ##__VA_ARGS__] UTF8String]);

#else

#define DLog(...)

#endif

// StringFormat
#define kSTRING_FORMAT(f, ...) [NSString stringWithFormat:f, ## __VA_ARGS__]


#define textSizeWidth(str,w,h,f) [str boundingRectWithSize:CGSizeMake(w,h) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:f} context:nil].size.width

#define TextSizeWidth(str,h,f)  [str boundingRectWithSize:CGSizeMake(10000,h) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:f]} context:nil].size.width


#endif /* Macro_h */
